# Maintainer: Sven-Hendrik Haase <svenstaro@gmail.com>
# Contributor: Aleksandar Trifunović <akstrfn at gmail dot com>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - disable test code (-DGSL_TEST=OFF) to fix 32-bit FTBFS, possibly fixed in the next version

_pkgname=GSL
pkgname=microsoft-gsl
pkgver=3.1.0
pkgrel=1
pkgdesc="C++ Core Guidelines Support Library"
arch=('any')
url="https://github.com/Microsoft/GSL"
license=('MIT')
makedepends=('cmake' 'git')
source=("$pkgname-$pkgver.tar.gz::https://github.com/Microsoft/GSL/archive/v${pkgver}.tar.gz")
sha256sums=('d3234d7f94cea4389e3ca70619b82e8fb4c2f33bb3a070799f1e18eef500a083')

prepare() {
    mkdir "$_pkgname-$pkgver"/build
}

build() {
    cd "$_pkgname-$pkgver"/build
    cmake .. \
        -DGSL_TEST=OFF \
        -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
        -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DCMAKE_BUILD_TYPE=Release

    make
}

check() {
    cd "$_pkgname-$pkgver"/build
    make test
}

package() {
    cd "$_pkgname-$pkgver"/build

    make DESTDIR="$pkgdir/" install

    cd ..
    install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
